﻿using CodeGeneratorBootstrap.Util;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace CodeGeneratorBootstrap
{
    public class MVC3Generator
    {
        public void Generate(int projectId, string outputPath)
        {
            CodeGeneratorBootstrap.Generators.MVC3Generator g = new CodeGeneratorBootstrap.Generators.MVC3Generator();
            g.Generate(projectId, outputPath);
        }

        public void DeleteDirectoryFolder(string strpath)
        {
            /*string[] filePaths = new string[] { "C:\\test\\Template", "C:\\test\\TT", "C:\\test\\TT2" };
            if (filePaths != null && filePaths.Length > 0)
            {
                var dirs = Directory.GetDirectories(strpath).Where(f => !filePaths.Select(i => i.ToLower()).Contains(f.ToLower()));
                foreach (var item in dirs)
                {
                    Directory.Delete(item, true);
                }
            }*/

            if (!Directory.Exists(strpath))
            {
                return;
            }

            var dirs = Directory.GetDirectories(strpath);
            foreach (var item in dirs)
            {
                Directory.Delete(item, true);
            }

            var files = Directory.GetFiles(strpath);
            foreach (var item in files)
            {
                File.Delete(item);
            }
        }

        public void CompressFile(string destPath, string sourcePath)
        {
            CZip.CreateZipDirectoryEntry(destPath, new System.IO.DirectoryInfo(sourcePath));
        }
    }
}
